package org.gw.building.repositories;

import org.gw.building.model.PrevDelayedExam;
import org.gw.building.model.StuInfo;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

public interface PrevDelayedExamRepository extends JpaRepository<PrevDelayedExam, String> {
	@Query("from PrevDelayedExam t where (?1 is null or t.stuInfo.term.id=?1) and (?2 is null or t.stuInfo.user.name like ?2 or t.stuInfo.user.uid like ?2)"
			+ " and (?3 is null or t.stuInfo.user.department=?3) and (?4 is null or t.stuInfo.classInfo.id=?4) and (?5 is null or t.stuInfo.sfwtzs =?5)")
	Page<PrevDelayedExam> query(String term, String likeString, String department, String clazz, Integer isTzs, Pageable pageable);

	PrevDelayedExam findFirstByStuInfo(StuInfo stuInfo);

}
